package com.example.a79273.shandianban.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;

import com.example.a79273.shandianban.R;
import com.example.a79273.shandianban.config.NetconfigStyle;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/8/31.
 */
public class StyleGvAdapter extends BaseAdapter{
    private List<String>mData;
    private Context context;

    public StyleGvAdapter(List<String> mData, Context context) {
        this.mData = mData;
        this.context = context;
    }

    @Override
    public int getCount() {
        return mData==null?0:mData.size();
    }

    @Override
    public Object getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if(convertView==null){
            convertView= LayoutInflater.from(context).inflate(R.layout.item_style_color,null);
            holder=new ViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }
        String color =NetconfigStyle.PIN_JIE+mData.get(position);
        Picasso.with(context).load(color).into(holder.imageView);
        return convertView;
    }
    static class ViewHolder{
        ImageView imageView;
        public ViewHolder(View v){
            imageView= (ImageView) v.findViewById(R.id.iv_style_color);
        }
    }
}

